#include <system/Screen.h>

namespace ne
{
    Screen::Screen()
        : mWidth(0),
          mHeight(0),
          mFullScreen(false)
    {
    }

    void Screen::setResolution(const uint32_t width, const uint32_t height)
    {
        if (mWidth != width || mHeight != height)
        {
            mWidth = width;
            mHeight = height;
            _fireResolutionChange();
        }
    }

    void Screen::setFullScreen(const bool b)
    {
        if (mFullScreen != b)
        {
            mFullScreen = b;
            _fireFullScreenChange();
        }
    }

    void Screen::addListener(Listener *pListener)
    {
        mListenerList.push_back(pListener);
    }

    void Screen::removeListener(Listener *pListener)
    {
        mListenerList.remove(pListener);
    }

    Screen::~Screen()
    {
    }

    void Screen::_fireResolutionChange()
    {
        for (ListenerListConstIterator it=mListenerList.begin(); it!=mListenerList.end(); ++it)
        {
            (*it)->onResolutionChange(getWidth(), getHeight());
        }
    }

    void Screen::_fireFullScreenChange()
    {
        for (ListenerListConstIterator it=mListenerList.begin(); it!=mListenerList.end(); ++it)
        {
            (*it)->onFullScreenChange(isFullScreen());
        }
    }
}
